﻿@using IsaGen
@inherits RazorLight.TemplatePage<IsaExtractor>
@{
    DisableEncoding = true;
    string FieldValue(InstructionField field)
    {
        var value = field.Value.HasValue ? field.Value.ToString() : field.CSharpName;
        if (field.IsEnum && field.CSharpType != "DataType")
        {
            return value;
        }
        return value;
    } 
}
// Copyright (c) Canaan Inc. All rights reserved.
// Licensed under the Apache license. See LICENSE file in the project root for full license information.
/* This file is generated by tools/stackvm_gen/IsaGen at @Raw(DateTimeOffset.Now.ToString()). */

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Nncase.IR;
using Nncase.Runtime.StackVM;

namespace Nncase.CodeGen.StackVM;

internal partial class CodeGenVisitor
{
    private void EmitTensorCall(Op op)
    {
        switch (op)
        {
@foreach (var ns in Model.TensorInstructions)
{
    foreach (var inst in ns.Value)
    {
@:            case IR.@(ns.Key).@(inst.CSharpName) top:
@:                Emitter.T.@(inst.CSharpName)(@string.Join(", ", inst.Fields.Where(x => x.Value == null).Select(x => $"top.{x.CSharpPropName}")));
@:                break;
    }
}
            default:
                throw new ArgumentException($"Unsupported op: {op}");
        }
    }
}
